﻿/*
 * Главная форма приложения
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DiplomNN
{
    public partial class StartForm : Form
    {
        private WebCam camera;

        public StartForm()
        {
            InitializeComponent();
            SelfRef = this;
        }

        public static StartForm SelfRef
        {
            get;
            set;
        }
        public void UpdateStartFormPB()
        {
            StartFormVideoPictureBox.Image = Helper.ImageFromStartFormVideoPB;
            StartFormFilteredPictureBox.Image = Helper.ImageFromStartFormFiltered;
            StartFormFilteredPictureBox2.Image = Helper.ImageFromStartFormFilteredBinary;
            TBPictureRecogn.Text = Helper.NamePictureRecognized; 
        }

        private void StartForm_Load(object sender, EventArgs e)
        {
            camera = new WebCam();
            camera.InitialWebCam();
            # region Загрузка настроек из памяти программы
            Helper.ColorsSettFrRmax = Settings.Default.Rmax;
            Helper.ColorsSettFrRmin = Settings.Default.Rmin;
            Helper.ColorsSettFrGmax = Settings.Default.Gmax;
            Helper.ColorsSettFrGmin = Settings.Default.Gmin;
            Helper.ColorsSettFrB = Settings.Default.B;
            Helper.ColorsSettFrB = 50;
            Helper.ColorsSettFrRG = Settings.Default.RG;

            Helper.ColorsSettFrHmax = Settings.Default.Hmax;
            Helper.ColorsSettFrHmin = Settings.Default.Hmin;
            Helper.ColorsSettFrSmax = Settings.Default.Smax;
            Helper.ColorsSettFrSmin = Settings.Default.Smin;
            Helper.ColorsSettFrVmax = Settings.Default.Vmax;
            Helper.ColorsSettFrVmin = Settings.Default.Vmin;

            Helper.ColorsSettFrYmax = Settings.Default.Ymax;
            Helper.ColorsSettFrYmin = Settings.Default.Ymin;
            Helper.ColorsSettFrCbmax = Settings.Default.Cbmax;
            Helper.ColorsSettFrCbmin = Settings.Default.Cbmin;
            Helper.ColorsSettFrCrmax = Settings.Default.Crmax;
            Helper.ColorsSettFrCrmin = Settings.Default.Crmin;
            # endregion

        }

        private void StartVideoButton_Click(object sender, EventArgs e)
        {
            camera.Start();
        }

        private void StopVideoButton_Click(object sender, EventArgs e)
        {
            camera.Stop();
        }

        private void ColorSettTSMenuItem_Click(object sender, EventArgs e)
        {
            ColorsSettingsForm CSFr = new ColorsSettingsForm();
            CSFr.Show();
        }

        private void TrainingTSMenuItem_Click(object sender, EventArgs e)
        {
            TrainingForm TrFr = new TrainingForm();
            TrFr.Show();
        }

        private void RBStartForm1_CheckedChanged(object sender, EventArgs e)
        {
            Helper.ChekButFromStartForm = 1;
        }

        private void RBStartForm2_CheckedChanged(object sender, EventArgs e)
        {
            Helper.ChekButFromStartForm = 2;
        }

        private void RBStartForm3_CheckedChanged(object sender, EventArgs e)
        {
            Helper.ChekButFromStartForm = 3;
        }

        private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void оПриложенииToolStripMenuItem_Click(object sender, EventArgs e)
        {
            About Ab = new About();
            Ab.Show();
        }
    }
}
